package com.testflow.hyh.request;

import com.testflow.hyh.entity.Bs;
import com.testflow.hyh.util.IdUtils;
import com.testflow.hyh.util.R;
import com.testflow.hyh.util.RandInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RequestMapping("/api/query")
@RestController
public class QueryRequest {

    protected final static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static List<Bs> list = new ArrayList<>();
    static {
        list.add(new Bs(IdUtils.fastSimpleUUID(), RandInfo.getFamilyName(),sdf.format(new Date()),sdf.format(new Date())));
        list.add(new Bs(IdUtils.fastSimpleUUID(), RandInfo.getFamilyName(),sdf.format(new Date()),sdf.format(new Date())));
    }
    @GetMapping("/getBs")
    public R getBsList(){
        return R.success(list);
    }

    @PostMapping("/addBs")
    public R addBs(){
        list.add(new Bs(IdUtils.fastSimpleUUID(), RandInfo.getFamilyName(),sdf.format(new Date()),sdf.format(new Date())));
        return R.success("添加成功");
    }
}
